note
  description: "Allows to read a file"
  author: "Adrien"
  date: "$Date$"
  revision: "$Revision$"

class
  READER

create
  make

feature{NONE}
  file_path: STRING;
  input_file : PLAIN_TEXT_FILE;

feature{ANY}
  make(path_to_file: STRING) is
  --make(fichier: STRING) is
    -- Constructor
    require
      path_to_file /= Void
    local
    do
      file_path := path_to_file
      create input_file.make(file_path)
      --pathToFile := fichier
      if input_file.access_exists then
          -- process
          read_file
      else
        io.put_string ("Unable to find file : " + path_to_file +"%N")
      end
  end -- make

  lines_in_file: INTEGER is
  -- The number of lines in filename

    local
      counter: INTEGER
    do
      counter := 0
      from
        input_file.read_line
      until
        input_file.end_of_file
      loop
        input_file.readline
        io.put_string(input_file.last_string + "%N")
        --print (input_file.last_string + "%N")
        counter := counter + 1
      end
      input_file.close
      Result := counter
    end -- lines_in_file

  read_file
    is
      -- Sequential Reading
    local
      parser : PARSER
      line : STRING
      compteur : INTEGER
    do
      input_file.open_read()
      if not input_file.is_open_read then
        io.put_string ("Unable to open file : " + file_path +"%N")
      else
	      create parser.make
	      compteur := 0
	      from
	        input_file.read_line
	      until
	        input_file.end_of_file
	      loop
	        line := input_file.last_string
	        if line /= Void then
		      compteur := compteur + 1
		      if compteur < 10 then
		      	io.put_string ("0")
		      end
		      io.put_integer (compteur)
	          io.put_string(  " > " + line + "%N")
	          parser.parseur(line)
	        end
	        --print (input_file.last_string + "%N")
	        input_file.read_line
	      end
	    end -- readFile
      input_file.close
      end
end
